#include <stdio.h>
#include <string.h>
#include <math.h>

	int a, b;
	int leva, levb, rowa, rowb;
	int step;

int getmid(int lev)
{
	return lev * lev - lev + 1;
}

int getlev(int x)
{
	return ((int) sqrt(x-1)) + 1;
}

main()
{
	int i;

	scanf("%ld%ld", &a, &b);
	if (a > b)
	{
		i = a; a = b; b = i;
	}
	leva = getlev(a);
	levb = getlev(b);
	rowa = a - getmid(leva);
	rowb = b - getmid(levb);

	step = 0;
	while (!(leva == levb && rowa == rowb))
	{
		if (leva == levb)
		{
			step += abs(rowa - rowb);
			rowa = rowb;
		} else
		{
			if ((leva & 1) != (rowa & 1)) // can down
			{
				leva++; step++;
			} else // cannot down
			{
				if (rowa < rowb)
				{
					rowa++; step++;
				} else
				{
					rowa--; step++;
				}
			}
		}
	}

	printf("%ld\n", step);
	return 0;
}
